
  $(document).ready(function(){
	  $('#comboxSearchfieldName').combobox({
			url: BASE_URL_FIELD_SEARCH + '/findAllOfCurrentUserCanManage' + '?v=' + Math.random(),
			valueField: 'id',
		    textField: 'name',
		    editable: false,
		    method:'get',
		    loadFilter: function(data){
		    	var allCheck = {'id':'','name':'全部'};
		    	data.content.unshift(allCheck);
		    	return data.content;
		    },
		    onSelect: function(record){
				
				if(record.id !== '')
				{
					comboxSearchSystemName.combobox({
					  disabled: false,
					  method:'get',
					  queryParams: {fieldId: record.id},
					  url: BASE_URL_FIELD_SYSTEM_SEARCH +'/findByFieldOfCurrentUserCanManage' + '?v=' + Math.random(),
					  valueField: 'id',
					  textField: 'name',
					  data:'',
					loadFilter: function(data){
						var allCheck = {'id':'','name':'全部'};
						data.content.unshift(allCheck);
						return data.content;
					},
					onLoadSuccess:function(){
						comboxSearchSystemName.combobox('setValue','');
					}
				  }).load();
				}else
				{
					comboxSearchSystemName.combobox({
					  disabled: true,
					  editable: false				  
					});
				}
		    },
		    onLoadSuccess:function(){
		    	$('#comboxSearchSystemName').combobox('setValue','');
		    }
		});
		
		//所属系统下拉框
		var comboxSearchSystemName = $('#comboxSearchSystemName').combobox({
        disabled: true,
        valueField: 'id',
        textField: 'name',
        editable: false,
		  data:[{id:'',name:'全部','selected':'true'}]
    });
	  
	  $("#datagrid").datagrid({
		  	url : '/api/tokens/getRouteTables' + '?v=' + Math.random(),
			method:'get',
			autoRowHeight:true,
			nowrap:false,
			pageSize:20,
			singleSelect:true,
			striped:true,
			pageList:[10,20,50,100],
			pagination:true,
			columns:[[
						{field:'fieldName',title:'领域',width:100},
						{field:'systemName',title:'系统',width:100},
						{field:'interfaceName',title:'接口',width:100},
						{field:'appSystemName',title:'调用方系统',width:300}
			      ]],
			      loadFilter:function(data){
						return {
							total: data.totalElements,
							rows: data.content
						};
					},
			onBeforeLoad:function(param){
				param.page -= 1;
				param.size = param.rows;
				delete param.rows;
				
//				param.sort = 'createTime,desc';
//				param.name = $('#txtSearch').val();
				
				var field = $("#comboxSearchfieldName").combobox("getValue");
				if(field!=""){
					param.fieldId = field;
				}
				var system = $("#comboxSearchSystemName").combobox("getValue");
				if(system!=""){
					param.systemId = system;
				}
				var interfaceName = $("#txtSearchInterfaceName").val();
				if(interfaceName!=""){
					param.interfaceName = interfaceName;
				}
				var appSystemName =$("#txtSearchAppSystemName").val();
				if(appSystemName!=""){
					param.appSystemName = appSystemName;
				}
				 
			}
		});

	  	$("#datagrid").datagrid('getPager').pagination({   
		    displayMsg:'当前显示从 [{from}] 到 [{to}] 共[{total}]条记录'
		});
		
});
  
  function search(){
		$("#datagrid").datagrid("reload", '/api/tokens/getRouteTables?v=' + Math.random());

	}
 
 	
 	
  
	